package com.burgeon.backend.EnterpriseWeChat.controller;

import com.burgeon.backend.EnterpriseWeChat.entity.Vip;
import com.burgeon.backend.EnterpriseWeChat.service.EWCustomerAssistantService;
import com.burgeon.backend.SHOP.entity.Goods;
import com.burgeon.backend.stsutil.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * @author: 伯俊软件
 * @description: 客服助手
 * @date: 2021/6/30 11:29
 * @param
 * @return
 */
@RestController
@CrossOrigin
@RequestMapping("ew/customer")
public class EWCustomerAssistantController extends EWBaseController {

    @Autowired
    private EWCustomerAssistantService ewCustomerAssistantService;

    /**
     * @author: 伯俊软件
     * @description: 商品展示及搜索
     * @date: 2021/6/30 11:52
     * @param content：商品名称或款号
     * @return com.burgeon.backend.stsutil.ResponseResult<java.util.List<com.burgeon.backend.SHOP.entity.Goods>>
     */
    @RequestMapping("findGoodsData")
    public ResponseResult<List<Goods>> findGoodsData(String content, String token){
        List<Goods> data =ewCustomerAssistantService.findGoodsData(content,token);
        return new ResponseResult<List<Goods>>(SUCCESS,data);
    }

    /**
     * @author: 伯俊软件
     * @description: 根据ID查询单个商品的信息
     * @date: 2021/6/30 13:23
     * @param id
     * @return com.burgeon.backend.stsutil.ResponseResult<com.burgeon.backend.SHOP.entity.Goods>
     */
    @RequestMapping("findGoodsById")
    public ResponseResult<Goods> findGoodsById(String id, String token){
        Goods data = ewCustomerAssistantService.findGoodsById(id,token);
        return new ResponseResult<Goods>(SUCCESS,data);
    }


    /**
     * @author: 伯俊软件
     * @description: 修改价格以及是否上架
     * @date: 2021/6/30 13:34
     * @param token
     * @param id
     * @param price：价格
     * @param isPutAway：是否商家 Y是N否
     * @return com.burgeon.backend.stsutil.ResponseResult<java.lang.Void>
     */
    @RequestMapping("updateGoodsData")
    public ResponseResult<Void> updateGoodsData(String token, String id, String price, String isPutAway){
        ewCustomerAssistantService.updateGoodsData(token,id,price,isPutAway);
        return new ResponseResult<Void>(SUCCESS);
    }


    /**
     * @author: 伯俊软件
     * @description: VIP档案修改列表
     * @date: 2021/6/30 15:50
     * @param nameOrCardNo：顾客姓名/卡号
     * @param range：请求条数
     * @return com.burgeon.backend.stsutil.ResponseResult<java.util.ArrayList<com.burgeon.backend.EnterpriseWeChat.entity.Vip>>
     */
    @RequestMapping("findVipData")
    public ResponseResult<ArrayList<Vip>> findVipData(String nameOrCardNo, int range, String token) throws Exception {
        ArrayList<Vip> data =  ewCustomerAssistantService.findVipData(nameOrCardNo,range,token);
        return new ResponseResult<ArrayList<Vip>>(SUCCESS,data);
    }


    /**
     * @author: 伯俊软件
     * @description: 通过会员ID查找单个会员信息
     * @date: 2021/6/30 16:27
     * @param token
     * @param id
     * @return com.burgeon.backend.stsutil.ResponseResult<com.burgeon.backend.EnterpriseWeChat.entity.Vip>
     */
    @RequestMapping("findVipDataById")
    public ResponseResult<Vip> findVipDataById(String token, String id) throws Exception {
       Vip data =  ewCustomerAssistantService.findVipDataById(token,id);
        return new ResponseResult<Vip>(SUCCESS,data);
    }


    /**
     * @author: 伯俊软件
     * @description: 修改会员档案
     * @date: 2021/6/30 17:25
     * @param token
     * @param id
     * @param img：头像
     * @param name
     * @param birthday
     * @param phone
     * @param cardNo：卡号
     * @return com.burgeon.backend.stsutil.ResponseResult<java.lang.Void>
     */
    @RequestMapping("updateVipData")
    public ResponseResult<Void> updateVipData(String token, String id, String img, String name, String birthday, String phone, String cardNo) throws Exception {
        ewCustomerAssistantService.updateVipData(token,id,img,name,birthday,phone,cardNo);
        return new ResponseResult<Void>(SUCCESS);
    }

}
